package main

import (
    "log"
    "net/rpc"
)

type ArithRequest struct{

    A int
    B int
}

type ArithResponse struct{
    Result int
}

func main() {

    //发起基于http协议的rpc调用
    conn, err := rpc.DialHTTP("tcp", "127.0.0.1:9528")
    if err != nil {
        log.Fatalln("dailing error: ", err)
    }

    req := ArithRequest{9, 2}
    var res ArithResponse

    err = conn.Call("Arith.Add", req, &res) // 加法运算
    if err != nil {
        log.Fatalln("arith error: ", err)
    }
    log.Println(res.Result)
    conn.Close()                    //如果不加Close()方法，则该连接一直保持EST状态


}
